package own.activeMQ.spring;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.TextMessage;

import org.springframework.jms.core.JmsTemplate;

public class JMSConsumer {
	
	JmsTemplate jmsTemplate=(JmsTemplate) SpringUtils.getBean("jmsTemplate");

	public Object receive(Destination destination){
		TextMessage tm = (TextMessage) jmsTemplate.receive(destination);
		return tm;
	}
	public Object receive(){
		Destination destination=jmsTemplate.getDefaultDestination();
		return receive(destination);
	}
	public static void main(String[] args) {
		Destination destination=(Destination)SpringUtils.getBean("test_queue");
		TextMessage tm1 = (TextMessage)new JMSConsumer().receive(destination);
		try {
			System.out.println("tm1:"+tm1.getText());
		} catch (JMSException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
